package com.ruoyi.mes.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.mes.domain.MesProcessExecDetails;
import com.ruoyi.mes.service.IMesProcessExecDetailsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 工艺执行-明细Controller
 * 
 * @author ruoyi
 * @date 2021-12-15
 */
@RestController
@RequestMapping("/processExecDetails")
public class MesProcessExecDetailsController extends BaseController
{
    @Autowired
    private IMesProcessExecDetailsService mesProcessExecDetailsService;

    /**
     * 查询工艺执行-明细列表
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:list")
    @GetMapping("/list")
    public TableDataInfo list(MesProcessExecDetails mesProcessExecDetails)
    {
        startPage();
        List<MesProcessExecDetails> list = mesProcessExecDetailsService.selectMesProcessExecDetailsList(mesProcessExecDetails);
        return getDataTable(list);
    }

    /**
     * 导出工艺执行-明细列表
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:export")
    @Log(title = "工艺执行-明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesProcessExecDetails mesProcessExecDetails) throws IOException
    {
        List<MesProcessExecDetails> list = mesProcessExecDetailsService.selectMesProcessExecDetailsList(mesProcessExecDetails);
        ExcelUtil<MesProcessExecDetails> util = new ExcelUtil<MesProcessExecDetails>(MesProcessExecDetails.class);
        util.exportExcel(response, list, "工艺执行-明细数据");
    }

    /**
     * 获取工艺执行-明细详细信息
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:query")
    @GetMapping(value = "/{processExecDetailUuid}")
    public AjaxResult getInfo(@PathVariable("processExecDetailUuid") String processExecDetailUuid)
    {
        return AjaxResult.success(mesProcessExecDetailsService.selectMesProcessExecDetailsByProcessExecDetailUuid(processExecDetailUuid));
    }

    /**
     * 新增工艺执行-明细
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:add")
    @Log(title = "工艺执行-明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesProcessExecDetails mesProcessExecDetails)
    {
        return toAjax(mesProcessExecDetailsService.insertMesProcessExecDetails(mesProcessExecDetails));
    }

    /**
     * 修改工艺执行-明细
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:edit")
    @Log(title = "工艺执行-明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesProcessExecDetails mesProcessExecDetails)
    {
        return toAjax(mesProcessExecDetailsService.updateMesProcessExecDetails(mesProcessExecDetails));
    }

    /**
     * 删除工艺执行-明细
     */
    @PreAuthorize(hasPermi = "mes:processExecDetails:remove")
    @Log(title = "工艺执行-明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{processExecDetailUuids}")
    public AjaxResult remove(@PathVariable String[] processExecDetailUuids)
    {
        return toAjax(mesProcessExecDetailsService.deleteMesProcessExecDetailsByProcessExecDetailUuids(processExecDetailUuids));
    }
}
